---------------------------------------------------------------------------------------------------------------------- -- STALKER NPC INFO ---------------------------------------------------------------------------------------------------------------------- function set_npc_info(npc, ini, scheme, section) --printf("INFO SECTION [%s]", utils_data.to_str(section)) local in_info = get_infos_from_data(npc, ini:r_string_ex(section,"in")) local out_info = get_infos_from_data(npc, ini:r_string_ex(section,"out")) for k,v in pairs(in_info) do npc:give_info_portion(v) end for k,v in pairs(out_info) do npc:disable_info_portion(v) end end function get_infos_from_data(npc, s) local t = {} local size_t = 0 if s then for name in string.gmatch( s, "(%|*[^%|]+%|*)%p*" ) do local condlist = xr_logic.parse_condlist(npc, "in", name, name) if condlist then size_t = size_t + 1 t[size_t] = xr_logic.pick_section_from_condlist(db.actor, npc, condlist) end end end return t end ---------------------------------------------------------------------------------------------------------------------- -- STALKER IGNORE MONSTER THRESHOLD ---------------------------------------------------------------------------------------------------------------------- -- Вызывается на переключении на новую секцию. Производит вычитывание настроек из текущей секции. function reset_threshold(npc, scheme, st, section) local threshold_section if scheme == nil or scheme == "nil" then threshold_section = st.ini:r_string_ex(st.section_logic,"threshold") else threshold_section = st.ini:r_string_ex(section,"threshold") end --'printf("THRESHOLD SECTION [%s]", utils_data.to_str(threshold_section)) if threshold_section then local max_ignore_distance = st.ini:r_float_ex(threshold_section,"max_ignore_distance") if max_ignore_distance then npc:max_ignore_monster_distance(max_ignore_distance) else npc:restore_max_ignore_monster_distance() end local ignore_monster = st.ini:r_float_ex(threshold_section,"ignore_monster_threshold") if ignore_monster then npc:ignore_monster_threshold(ignore_monster) else npc:restore_ignore_monster_threshold() end end end ---------------------------------------------------------------------------------------------------------------------- -- STALKER MAP SHOW ---------------------------------------------------------------------------------------------------------------------- -- Вызывается на переключении на новую секцию. Производит вычитывание настроек из текущей секции. function reset_show_spot(npc, scheme, st, section) local npc_id = npc:id() remove_level_spot(npc_id) local sim = alife() local se_obj = sim:object(npc_id) if not (se_obj) then return end local map_spot local map_spot_condlist = st.ini:r_string_to_condlist(st.section_logic,"level_spot") or st.ini:r_string_to_condlist(section,"level_spot") if (map_spot_condlist) then map_spot = xr_logic.pick_section_from_condlist(db.actor, npc, map_spot_condlist) end local show_spot = "true" map_spot_condlist = st.ini:r_string_to_condlist(st.section_logic,"show_spot") or st.ini:r_string_to_condlist(section,"show_spot") if (map_spot_condlist) then show_spot = xr_logic.pick_section_from_condlist(db.actor, npc, map_spot_condlist) end se_obj:visible_for_map(show_spot == "true" or false) if not (map_spot) then return end local map_location local hint = "" if map_spot == "special" then map_location = "ui_pda2_special_location" hint = "st_ui_pda_legend_special" elseif map_spot == "trader" then map_location = "ui_pda2_trader_location" hint = "st_ui_pda_legend_trader" elseif map_spot == "mechanic" then map_location = "ui_pda2_mechanic_location" hint = "st_ui_pda_legend_mechanic" elseif map_spot == "guider" then map_location = "ui_pda2_scout_location" hint = "st_ui_pda_legend_scout" elseif map_spot == "barman" then map_location = "ui_pda2_barman_location" hint = "st_ui_pda_legend_barman" elseif map_spot == "quest_npc" then map_location = "ui_pda2_quest_npc_location" hint = "st_ui_pda_legend_vip" elseif map_spot == "medic" then map_location = "ui_pda2_medic_location" hint = "st_ui_pda_legend_medic" elseif map_spot == "companion" then map_location = "ui_pda2_companion_location" hint = "st_ui_pda_companion" end if (map_location and db.actor and npc:general_goodwill(db.actor) > -1000) then level.map_add_object_spot(npc_id, map_location, hint) end end function remove_level_spot(npc_id) if level.map_has_object_spot(npc_id, "ui_pda2_special_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_special_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_trader_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_trader_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_barman_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_barman_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_mechanic_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_mechanic_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_scout_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_scout_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_quest_npc_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_quest_npc_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_medic_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_medic_location") elseif level.map_has_object_spot(npc_id, "ui_pda2_companion_location") ~= 0 then level.map_remove_object_spot(npc_id, "ui_pda2_companion_location") end end --'-------------------------------------------------------------------------------------------------------------------- --' INVULNERABILITY --'-------------------------------------------------------------------------------------------------------------------- function is_need_invulnerability(npc) local id = npc:id() -- remove invulnerability on bounties for task_id,npc_id in pairs(axr_task_manager.bounties_by_id) do if (npc_id == id) then return false end end local npc_st = db.storage[id] if not (npc_st and npc_st.ini) then return false end local condlist = npc_st.ini:r_string_to_condlist(npc_st.section_logic,"invulnerable") or npc_st.active_section and npc_st.ini:r_string_to_condlist(npc_st.active_section,"invulnerable") if not (condlist) then return false end return xr_logic.pick_section_from_condlist(db.actor,npc,condlist) == "true" end --' Вызывается на переключении на новую секцию. Производит вычитывание настроек из текущей секции. function reset_invulnerability(npc, ini, section) local invulnerability = is_need_invulnerability(npc) --printf("RESET INVULNERABILITY. npc[%s] = [%s]", npc:name(), tostring(invulnerability)) if npc:invulnerable() ~= invulnerability then npc:invulnerable(invulnerability) end end function disable_invulnerability(npc) --printf("DISABLE INVULNERABILITY. npc[%s] = [false]", npc:name()) --npc:invulnerable(false) end function update_invulnerability(npc) local invulnerability = is_need_invulnerability(npc) if npc:invulnerable() ~= invulnerability then --printf("UPDATE INVULNERABILITY. npc[%s] = [%s]", npc:name(), tostring(invulnerability)) npc:invulnerable(invulnerability) end end --'-------------------------------------------------------------------------------------------------------------------- --' TEAM SQUAD GROUP --'-------------------------------------------------------------------------------------------------------------------- --' Вызывается на переключении на новую секцию. Производит вычитывание настроек из текущей секции. function reset_group(npc, ini, section) local group = ini:r_float_ex(section,"group") or -1 if group ~= -1 then npc:change_team(npc:team(), npc:squad(), group) end end function take_items_enabled(npc, scheme, st, section) local take_items = nil if(st.ini:line_exist(section, "take_items")) then take_items = st.ini:r_bool_ex(section,"take_items",true) else take_items = st.ini:r_bool_ex(st.section_logic,"take_items",true) end npc:take_items_enabled(take_items) end function can_select_weapon(npc, scheme, st, section) local str = st.ini:r_string_ex(st.section_logic,"can_select_weapon") or st.ini:r_string_ex(section,"can_select_weapon") or "true" local cond = xr_logic.parse_condlist(npc, section, "can_select_weapon", str) local can = xr_logic.pick_section_from_condlist(db.actor, npc, cond) npc:can_select_weapon(can=="true") end